package com.oppo.skywalking.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oppo.skywalking.dao.EmployeeDao;
import com.oppo.skywalking.entity.Employee;
import com.oppo.skywalking.service.EmployeeService;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

/**
 * 雇员表(employee)表服务实现类
 * @author makejava
 * @since 2022-11-06 13:16:32
 */
@Slf4j
@Service("employeeService")
public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, Employee> implements EmployeeService {

    @Resource
    private EmployeeDao employeeDao;

    @Trace
    @Tags({@Tag(key = "findById", value = "returnObj")})
    @Override
    public Employee findById(Long id) {
        Employee employee = employeeDao.selectById(id);
        log.info("employee = {}", employee);
        Assert.notNull(employee, "该员工不存在");
        return employee;
    }
}
